package ar.edu.unq.wannaplay.users;

import ar.edu.unq.wannaplay.entity.Entity;

public class User extends Entity {
    private static final long serialVersionUID = 1L;

    private String username;

    private String password;

    private Role role;

    public String getUsername() {
        return username;
    }

    public User() {
        super();
    }

    public User(final String username, final String password, final Role role) {
        super();
        this.username = username;
        this.password = password;
        this.role = role;
    }

    public void setUsername(final String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(final String password) {
        this.password = password;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(final Role role) {
        this.role = role;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof User)) {
            return false;
        }

        User other = (User) obj;

        if (this.getId() == other.getId()) {
            return true;
        }
        if ((Integer) this.getId() == null) {
            return false;
        }

        // equivalence by id
        return ((Integer) this.getId()).equals(other.getId());
    }

    @Override
    public int hashCode() {
        if ((Integer) this.getId() != null) {
            return ((Integer) this.getId()).hashCode();
        } else {
            return super.hashCode();
        }
    }
}
